(function(fields){
	
	var datatype = {
		"string":"textfield",
		"String":"textfield",
		"text"	:"textarea",
		"int"   :"numberfield",
		"date"  :"datefield",
		"float"	:"numberfield",
		"combo" :"combobox",
		"obj"	:"triggerfield",
		"list"  :""
	};
	
	var items   = []; 
	var	tempk=0,tempx=0;
	var jianju = 34;	//间距
	
	fields.sort(function(a,b){
		return a.index>b.index;
	});
	
	for(f in fields){
		var x,y,anchor;
		if(tempk%2==0){
			x=10;
			y=(tempx*jianju)+10;
			anchor="50%";
		}else{
			x=(550/2+6);
			y=(tempx*jianju)+10;
			anchor="98%";
			tempx+=1;
		}
		if(fields[f].type=="text"){
			y=(tempx*jianju)+10;
			anchor="98%";
			x=10;
			tempx+=2.6;
			tempk=1;
		}
		
		if(fields[f].type=="obj"){
			items.push({
				x: x,
	            y: y,
	    		anchor:anchor,
				maxLength 	: fields[f].length,
				labelWidth	: 65,  
				xtype     	: datatype[fields[f].type],
				trigger1Cls	: Ext.baseCSSPrefix  +  'form-search-trigger',
				fieldLabel	: fields[f].text,
				format		: 'Y-m-d h:i:s',
				id	      	: fields[f].name,
				onTriggerClick	: function () {
					_("entity.add.fun.selectpanel")("entity.list",fields[f].clazz,fields[f].text,function(id){
						//var seletdb = _("tools.getSelect")(id);
						var seletdb = Ext.getCmp(id).getSelectionModel().getSelection();
						if(seletdb.length>0){
							//log(seletdb[0].data["id"]);
							Ext.getCmp(fields[f].name).setValue(seletdb[0].data[fields[f].clazzQuery]);
							Ext.getCmp(fields[f].name+"_id").setValue(seletdb[0].data["id"]);
							//return true;
						}else{
							Ext.getCmp(fields[f].name).setValue("");
							Ext.getCmp(fields[f].name+"_id").setValue("");
						}
						return true;
					});
				}
			});
			items.push({//隐藏对象
				id	  : fields[f].name+"_id",
				xtype : 'hiddenfield'
			});
		}else if(fields[f].type=="list"){
			
		}else{
			items.push({
				x: x,
	            y: y,
	    		anchor:anchor,
				maxLength 	: fields[f].length,
				labelWidth	: 65,  
				xtype     	: datatype[fields[f].type],
				fieldLabel	: fields[f].text,
				format		: 'Y-m-d h:i:s',
				id	      	: fields[f].name
				//regex:eval"",
				//regexText
			});
		} 
		tempk++;
	}
	
	return items;
})